
function viewGallery(){
     var xh = loadXMLDoc();
    var url = "gallery.php";

    xh.onreadystatechange = view_u;

    function view_u(){
        if (xh.readyState==4){
        document.getElementById("content").innerHTML=xh.responseText;
    		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function viewGallery(UserTujuan){
     var xh = loadXMLDoc();
    var url = "gallery.php?UserTujuan="+UserTujuan+"&self";

    xh.onreadystatechange = view_u;

    function view_u(){
        if (xh.readyState==4){
        	document.getElementById("content").innerHTML=xh.responseText;
    	}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function viewEditPhoto(photo_id){
     var xh = loadXMLDoc();
    var url = "gallery.php?edit=1&photo_id="+photo_id+"&self";

    xh.onreadystatechange = view_u;

    function view_u(){
        if (xh.readyState==4){
        	document.getElementById("content").innerHTML=xh.responseText;
    	}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

/*
function viewPhoto(photo_id){
     var xh = loadXMLDoc();
    var url = "gallery.php?view=2&photo_id="+photo_id+"&self";

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
        document.getElementById("content").innerHTML=xh.responseText;
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}*/

function viewPhoto(photo_id, user_tujuan, usr_tag){
     var xh = loadXMLDoc();
	 if (user_tujuan!=null) {
		if (usr_tag==null)
			var url = "gallery.php?view=2&photo_id="+photo_id+"&UserTujuan="+user_tujuan+"&self";
		else
			var url = "gallery.php?view=2&photo_id="+photo_id+"&UserTujuan="+user_tujuan+"&self&usr_tag="+usr_tag;
	} else {
		if (usr_tag==null)
			var url = "gallery.php?view=2&photo_id="+photo_id+"&self";
		else
			var url = "gallery.php?view=2&photo_id="+photo_id+"&self&usr_tag="+usr_tag;
	}

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
        document.getElementById("content").innerHTML=xh.responseText;
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}



function submitComment(photo_id, comment, UserTujuan){
     var xh = loadXMLDoc();
	if (UserTujuan!=null)
    var url = "gallery_serv.php?view=2&photo_id="+photo_id+"&comment="+comment;
	else
	var url = "gallery_serv.php?view=2&photo_id="+photo_id+"&comment="+comment+"&UserTujuan="+UserTujuan;

    xh.onreadystatechange = view_u;

    function view_u(){
           if (xh.readyState==4){
        		document.getElementById("comment_content_photo").innerHTML+=xh.responseText;
				document.getElementById('text_comment_photo').value = "Add a comment";
    		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function deleteComment(photo_comment_id,photo_id){
     var xh = loadXMLDoc();
    var url = "gallery_serv.php?delete_comment=1&photo_comment_id="+photo_comment_id+"&photo_id="+photo_id;

    xh.onreadystatechange = view_u;

    function view_u(){
        if (xh.readyState==4){
				var a = xh.responseText;
				var less = document.getElementById("less_comment_photo");
				less.innerHTML = a;
				var parent = document.getElementById('comment_content_photo');
				var del = document.getElementById('photo_comment_content'+photo_comment_id);
				parent.removeChild(del);
    		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}



function viewAllComment(photo_id) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?viewAllComment=1&photo_id="+photo_id;

    xh.onreadystatechange = view_u;

    function view_u(){
		if (xh.readyState==4){
			var text = xh.responseText.split("/*tagtag*/");
			document.getElementById('less_comment_photo').innerHTML = text[0];
			document.getElementById('comment_content_photo').innerHTML = text[1];
		}
		//else {
			//alert("Problem retrieving data:" + xh.statusText);
		//}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function viewLessComment(photo_id) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?viewLessComment=1&photo_id="+photo_id;

    xh.onreadystatechange = view_u;

    function view_u(){
        if (xh.readyState==4){
			var text = xh.responseText.split("/*tagtag*/");
			document.getElementById('less_comment_photo').innerHTML = text[0];
			document.getElementById('comment_content_photo').innerHTML = text[1];
    	}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function arrow_click(photo_id) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?view=2&photo_id="+photo_id+"&arrow_click=1";

    xh.onreadystatechange = view_u;

    function view_u(){
        if (xh.readyState==4){
			var text = xh.responseText.split("/*tagtag*/");
			document.getElementById("content_photo_gedhe").innerHTML=text[0];
			document.getElementById("rating_content").innerHTML=text[1];
			document.getElementById("uploader_name").innerHTML=text[2];
			document.getElementById("uploader_keyword").innerHTML=text[3];
			document.getElementById("uploader_description").innerHTML=text[4];
			document.getElementById("uploader_datecaptured").innerHTML=text[5];
			document.getElementById("uploader_dateupload").innerHTML=text[6];
			document.getElementById("uploader_category").innerHTML=text[7];
			document.getElementById("uploader_privacy").innerHTML=text[8];
			document.getElementById("uploader_permission").innerHTML=text[9];
			document.getElementById("middle_column").innerHTML=text[10];	
			document.getElementById("right_column").innerHTML=text[11];
			}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function arrow_click(photo_id, UserTujuan) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?view=2&photo_id="+photo_id+"&arrow_click=1&UserTujuan="+UserTujuan;

    xh.onreadystatechange = view_u;

    function view_u(){
        if (xh.readyState==4){
			var text = xh.responseText.split("/*tagtag*/");
			document.getElementById("content_photo_gedhe").innerHTML=text[0];
			document.getElementById("rating_content").innerHTML=text[1];
			document.getElementById("uploader_name").innerHTML=text[2];
			document.getElementById("uploader_keyword").innerHTML=text[3];
			document.getElementById("uploader_description").innerHTML=text[4];
			document.getElementById("uploader_datecaptured").innerHTML=text[5];
			document.getElementById("uploader_dateupload").innerHTML=text[6];
			document.getElementById("uploader_category").innerHTML=text[7];
			document.getElementById("uploader_privacy").innerHTML=text[8];
			document.getElementById("uploader_permission").innerHTML=text[9];
			document.getElementById("middle_column").innerHTML=text[10];	
			document.getElementById("right_column").innerHTML=text[11];
			}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function makeprofpic(photo_id) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?profpic=1&photo_id="+photo_id;

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
        document.getElementById("photo_comment").innerHTML=xh.responseText;
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function removePhoto(photo_id) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?remove=1&photo_id="+photo_id;

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange
	var r=confirm("Confirm to delete this photo");
	if (r==true)
	  {
	    xh.open("GET",url,true);
		xh.send(null);
		viewGallery();
	  }
	else
	  {
	  	alert("You pressed Cancel!");
	  }
}

function decreaseRating(photo_id) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?decreaserating=1&photo_id="+photo_id;

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
        document.getElementById("rating_text").innerHTML=xh.responseText;
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function increaseRating(photo_id) {
	var xh = loadXMLDoc();
    var url = "gallery_serv.php?increaserating=1&photo_id="+photo_id;

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
        document.getElementById("rating_text").innerHTML=xh.responseText;
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function change_page_photo(page_photo, Defaultt, UserTujuan) {
	var xh = loadXMLDoc();
	if (UserTujuan==null)
	    var url = "gallery_serv.php?changepagephoto="+page_photo+"&default="+Defaultt;
	else
		var url = "gallery_serv.php?changepagephoto="+page_photo+"&UserTujuan="+UserTujuan+"&default="+Defaultt;

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
        document.getElementById("photo_atas").innerHTML=xh.responseText;
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function change_page_phototag(page_photo, Defaultt, UserTujuan) {
	var xh = loadXMLDoc();
	if (UserTujuan==null)
	    var url = "gallery_serv.php?changepagephototag="+page_photo+"&default="+Defaultt;
	else
		var url = "gallery_serv.php?changepagephototag="+page_photo+"&UserTujuan="+UserTujuan+"&default="+Defaultt;

    xh.onreadystatechange = view_u;

    function view_u(){
        //   if (xh.readyState==4 || xh.readyState=="complete"){
        document.getElementById("photo_bawah").innerHTML=xh.responseText;
    //		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}

function changeViewSumPhotos(jumlah, UserTujuan) {
	var xh = loadXMLDoc();
	if (UserTujuan==null)
	    var url = "gallery_serv.php?sumphotoschange="+jumlah;
	else
		var url = "gallery_serv.php?sumphotoschange="+jumlah+"&UserTujuan="+UserTujuan;

    xh.onreadystatechange = view_u;

    function view_u(){
            if (xh.readyState==4){
				var arr = xh.responseText.split("/*tagtag*/");
        		document.getElementById("photo_atas").innerHTML= arr[0];
        		document.getElementById("photo_bawah").innerHTML= arr[1];
    		}
    //		else {
    //			alert("Problem retrieving data:" + xh.statusText);
    //		}
    }
    //URLnya
    //onreadystatechange

    xh.open("GET",url,true);
    xh.send(null);
}



